package com.lg.service.impl;

import java.util.HashMap;
import java.util.Map;

import com.lg.model.StPromoter;
import com.lg.model.exception.BusinessException;
import com.lg.model.exception.OtherException;
import com.lg.serivce.StPromoterService;

public class StPromoterServiceImpl extends GenericServiceImpl<StPromoter>
		implements StPromoterService {

	@Override
	public StPromoter findPromoterUser(String regid, String pwd)
			throws BusinessException, OtherException {
		StPromoter sp = null;
		if (regid != null && !"".equals(regid) && pwd != null
				&& !"".equals(pwd)) {
			Map param = new HashMap();
			param.put("regId", regid);
			param.put("promoterPwd", pwd);
			try {
				sp = getBaseDAO().getStPromoterDAO().selectObjectByStatementId("findPromoterUser", param);
			} catch (Exception e) {
				e.printStackTrace();
				throw new OtherException(e.getMessage());
			}
		}
		return sp;
	}

	@Override
	public StPromoter findLoadPromoterUser(String promoterid, String regid)
			throws BusinessException, OtherException {
		StPromoter sp = null;
		if (promoterid != null && !"".equals(promoterid) && regid != null
				&& !"".equals(regid)) {
			Map param = new HashMap();
			param.put("promoterId", promoterid);
			param.put("regId", regid);
			try {
				sp = getBaseDAO().getStPromoterDAO().selectObjectByStatementId("loadPromoterUser", param);
			} catch (Exception e) {
				e.printStackTrace();
				throw new OtherException(e.getMessage());
			}
		}
		return sp;
	}
}
